package com.itheima.calendar;

import java.util.Calendar;
import java.util.Scanner;

public class CalendarTest2 {
    /*
    需求: 键盘录入一个年份,使用日历类完成该年母亲节的日期打印.
        母亲节: 5月的第二个星期日
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个年份");
        int year = sc.nextInt();
        Calendar calendar = Calendar.getInstance();
        calendar.set(year,4,1);
        /*int week = calendar.get(Calendar.DAY_OF_WEEK)-1;
        System.out.println(week);*/
        int i = calendar.get(Calendar.DAY_OF_WEEK)-1;

        if(i != 0) {
            int j = 14-i;
            calendar.add(Calendar.DATE, j);
        }else{
            int j = i+7;
            calendar.add(Calendar.DATE, j);
        }
        System.out.println("今年的母亲节是:");
        System.out.println((calendar.get(calendar.MONTH)+1)+"月"+calendar.get(Calendar.DATE)+"号");
    }
}
